#include <iostream>
#include <memory>
#include <jsoncpp/json/json.h>
#include <string>

int main()
{
    std::string str = R"({"姓名":"小黑", "年龄":18, "成绩":[100, 23.3, 90.0]})";

    Json::Value root;
    Json::CharReaderBuilder crb;
    std::unique_ptr<Json::CharReader> cr(crb.newCharReader());

    //反序列化1
    std::string errs;
    bool ret = cr->parse(str.c_str(), str.c_str()+str.size(), &root, &errs);//参数:起始 结束 Json, 出错信息
    if(!ret)
    {
        std::cout << "parse error: " << errs << std::endl;
        return -1;
    }
    //打印
    std::cout << root["姓名"].asString() << std::endl;
    std::cout << root["年龄"].asString() << std::endl;
    int sz = root["成绩"].size();//获取成绩数组得大小
    for(int i = 0; i < sz; ++i)
    {
        std::cout << root["成绩"][i] << " ";
    }
    std::cout << std::endl;

    return 0;
}